package snapex.expense.mapper;

import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static snapex.expense.mapper.UserGroupsDynamicSqlSupport.*;

import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import snapex.core.model.UserGroups;

@Mapper
public interface HtcUserGroupsMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<UserGroups> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("UserGroupsResult")
    UserGroups selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="UserGroupsResult", value = {
        @Result(column="ugp_name", property="ugpName", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="ugp_desc", property="ugpDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="ugp_appid", property="ugpAppid", jdbcType=JdbcType.VARCHAR),
        @Result(column="ugp_type", property="ugpType", jdbcType=JdbcType.INTEGER),
        @Result(column="ugp_cat", property="ugpCat", jdbcType=JdbcType.INTEGER),
        @Result(column="ugp_cost_centre", property="ugpCostCentre", jdbcType=JdbcType.VARCHAR),
        @Result(column="ugp_parent", property="ugpParent", jdbcType=JdbcType.VARCHAR)
    })
    List<UserGroups> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(userGroups);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, userGroups);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String ugpName_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, userGroups)
                .where(ugpName, isEqualTo(ugpName_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(UserGroups record) {
        return insert(SqlBuilder.insert(record)
                .into(userGroups)
                .map(ugpName).toProperty("ugpName")
                .map(ugpDesc).toProperty("ugpDesc")
                .map(ugpAppid).toProperty("ugpAppid")
                .map(ugpType).toProperty("ugpType")
                .map(ugpCat).toProperty("ugpCat")
                .map(ugpCostCentre).toProperty("ugpCostCentre")
                .map(ugpParent).toProperty("ugpParent")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(UserGroups record) {
        return insert(SqlBuilder.insert(record)
                .into(userGroups)
                .map(ugpName).toPropertyWhenPresent("ugpName", record::getUgpName)
                .map(ugpDesc).toPropertyWhenPresent("ugpDesc", record::getUgpDesc)
                .map(ugpAppid).toPropertyWhenPresent("ugpAppid", record::getUgpAppid)
                .map(ugpType).toPropertyWhenPresent("ugpType", record::getUgpType)
                .map(ugpCat).toPropertyWhenPresent("ugpCat", record::getUgpCat)
                .map(ugpCostCentre).toPropertyWhenPresent("ugpCostCentre", record::getUgpCostCentre)
                .map(ugpParent).toPropertyWhenPresent("ugpParent", record::getUgpParent)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<UserGroups>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, ugpName, ugpDesc, ugpAppid, ugpType, ugpCat, ugpCostCentre, ugpParent)
                .from(userGroups);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<UserGroups>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, ugpName, ugpDesc, ugpAppid, ugpType, ugpCat, ugpCostCentre, ugpParent)
                .from(userGroups);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UserGroups selectByPrimaryKey(String ugpName_) {
        return SelectDSL.selectWithMapper(this::selectOne, ugpName, ugpDesc, ugpAppid, ugpType, ugpCat, ugpCostCentre, ugpParent)
                .from(userGroups)
                .where(ugpName, isEqualTo(ugpName_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(UserGroups record) {
        return UpdateDSL.updateWithMapper(this::update, userGroups)
                .set(ugpName).equalTo(record::getUgpName)
                .set(ugpDesc).equalTo(record::getUgpDesc)
                .set(ugpAppid).equalTo(record::getUgpAppid)
                .set(ugpType).equalTo(record::getUgpType)
                .set(ugpCat).equalTo(record::getUgpCat)
                .set(ugpCostCentre).equalTo(record::getUgpCostCentre)
                .set(ugpParent).equalTo(record::getUgpParent);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(UserGroups record) {
        return UpdateDSL.updateWithMapper(this::update, userGroups)
                .set(ugpName).equalToWhenPresent(record::getUgpName)
                .set(ugpDesc).equalToWhenPresent(record::getUgpDesc)
                .set(ugpAppid).equalToWhenPresent(record::getUgpAppid)
                .set(ugpType).equalToWhenPresent(record::getUgpType)
                .set(ugpCat).equalToWhenPresent(record::getUgpCat)
                .set(ugpCostCentre).equalToWhenPresent(record::getUgpCostCentre)
                .set(ugpParent).equalToWhenPresent(record::getUgpParent);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(UserGroups record) {
        return UpdateDSL.updateWithMapper(this::update, userGroups)
                .set(ugpDesc).equalTo(record::getUgpDesc)
                .set(ugpAppid).equalTo(record::getUgpAppid)
                .set(ugpType).equalTo(record::getUgpType)
                .set(ugpCat).equalTo(record::getUgpCat)
                .set(ugpCostCentre).equalTo(record::getUgpCostCentre)
                .set(ugpParent).equalTo(record::getUgpParent)
                .where(ugpName, isEqualTo(record::getUgpName))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(UserGroups record) {
        return UpdateDSL.updateWithMapper(this::update, userGroups)
                .set(ugpDesc).equalToWhenPresent(record::getUgpDesc)
                .set(ugpAppid).equalToWhenPresent(record::getUgpAppid)
                .set(ugpType).equalToWhenPresent(record::getUgpType)
                .set(ugpCat).equalToWhenPresent(record::getUgpCat)
                .set(ugpCostCentre).equalToWhenPresent(record::getUgpCostCentre)
                .set(ugpParent).equalToWhenPresent(record::getUgpParent)
                .where(ugpName, isEqualTo(record::getUgpName))
                .build()
                .execute();
    }
}